package com.Lyf.common.vo;


import com.Lyf.common.constant.ResultConstant;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

public class ResultVO extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    //构造方法
    public ResultVO()
    {
        put("code", ResultConstant.SUCCESS_CODE);
        put("message", ResultConstant.SUCCESS_MESSAGE);
    }

    public ResultVO put(String key, Object value)
    {
        super.put(key, value);
        return this;
    }

    public static ResultVO success()
    {
        return new ResultVO();
    }

    public static ResultVO success(String message)
    {
        ResultVO resultVO = new ResultVO();
        resultVO.put("message", message);
        return resultVO;
    }

    public static ResultVO success(Map<String, Object> map)
    {
        ResultVO resultVO = new ResultVO();
        resultVO.putAll(map);
        return resultVO;
    }

    public static ResultVO error(Integer code, String message)
    {
        ResultVO resultVO = new ResultVO();
        resultVO.put("code", code);
        resultVO.put("message", message);
        return resultVO;
    }

    public static ResultVO error()
    {
        return error(ResultConstant.ERROR_CODE, ResultConstant.ERROR_MESSAGE);
    }

    public static ResultVO error(String message)
    {
        ResultVO resultVO = new ResultVO();
        resultVO.put("message", message);
        return resultVO;
    }



}
